# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=bzrtp
pkgver=5.1.45
pkgrel=0
pkgdesc="BZRTP is an opensource implementation of ZRTP keys exchange protocol"
url="https://gitlab.linphone.org/BC/public/bzrtp"
arch="all"
license="GPL-3.0-only"
makedepends="cmake bctoolbox-dev sqlite-dev libxml2-dev samurai"
#options="!check" # no tests
subpackages="$pkgname-dev"
source="https://gitlab.linphone.org/BC/public/bzrtp/-/archive/$pkgver/bzrtp-$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DENABLE_STATIC=False \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
64dd1eb8307643e7088f8900c4a9f1180e0a270e37d340e809adae22758dfc5b6da04eb979fa81563bccd2cea7e2f771d2ba2ef2f846bbbb1bb27bafa8cc19f7  bzrtp-5.1.45.tar.gz
"
